package com.ruoyi.buss.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.buss.domain.*;
import com.ruoyi.buss.mapper.*;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.JsonHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Author : ChenBei
 * Date : 2021/10/8 10:18
 * Description : 账务信息报表
 **/
@Service
public class ReportService extends ServiceImpl<AccountingMapper, Accounting> {


    /**
     * 账务报表-首页
     *
     * @param vo
     * @return
     */
    public List<AccountingVO> accountingReport(AccountingVO vo)
    {
        return getBaseMapper().accountingReport(vo);
    }


    /**
     * 账务月报表-首页
     *
     * @param vo
     * @return
     */
    public AjaxResult reportMon(AccountingVO vo)
    {
        List<AccountingVO> reList = new ArrayList<AccountingVO>();
        List<AccountingVO> list = getBaseMapper().reportMon(vo);
        for(int i=1;i<=12;i++){
            AccountingVO temp = new AccountingVO();
            temp.setExpenditure("0");
            temp.setAllIncome("0");
            temp.setProfit("0");
            temp.setMon(i+"");
            for(int j=0;j<list.size();j++){
                if(Integer.parseInt(list.get(j).getMon()) == i){
                    temp = JsonHelper.o2m(list.get(j),AccountingVO.class);
                    break;
                }
            }
            reList.add(temp);
        }
        return AjaxResult.success( reList );
    }
}
